package com.xywy.beautyand.base;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.View;
import android.view.View.OnClickListener;

import com.xywy.beautyand.R;
import com.xywy.beautyand.util.NetUtil;
import com.xywy.beautyand.util.UIUtil;
import com.xywy.beautyand.vollery.BaseRequest;
import com.xywy.beautyand.vollery.VolleyManager;

/**
<<<<<<< HEAD
 * *****************************************  
* @Title: BaseFragment.java 
* @Package com.xywy.bloodandroid.base 
* @Description: TODO(Fragment 基类  �?�� 基本方法 封装) 
* @author smz
* @date 2014-12-23 上午11:05:38 
* @version V1.0   
*******************************************
 */
	
public class BaseFragment extends Fragment implements OnClickListener {

	protected ProgressDialog waittingDialog;

	public void waitingDialog(Context context, String message) {
		if (waittingDialog == null)
			waittingDialog = new ProgressDialog(context);
		waittingDialog.setCanceledOnTouchOutside(false);//
		waittingDialog.setMessage(message);
		waittingDialog.show();
	}

	/**
	 * 
	 * 
	 * @param request
	 * @return
	 */
	protected boolean executeRequest(BaseRequest<?> request) {
		if (NetUtil.hasNetwork(getActivity())) {
			waitingDialog(getActivity(),
					getResources().getString(R.string.request));
			VolleyManager.addRequest(request, this);
			return true;
		} else {
			UIUtil.showToast(getActivity(),
					getResources().getString(R.string.not_network));
			UIUtil.DissDialog(getActivity(), waittingDialog);
			return false;
		}
	}
	@Override
	public void onClick(View arg0) {
		
	}

	
	
	public void openActivity(Class<?> c) {
		Intent intent = new Intent(getActivity(), c);
		startActivity(intent);
	}

}
